package com.itheima.dao;

import com.itheima.pojo.PictureSort;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.common.Mapper;

public interface PictureSortMapper extends Mapper<PictureSort> {

    /**
     * 获取排序字段的最大值
     * @return
     */
    @Select("select MAX(sort) from t_picture_sort")
    int getMax();

    /**
     * 置顶操作
     * @param uid
     * @param num
     * @return
     */
    @Update("update t_picture_sort set sort=#{num} where uid=#{uid}")
    int stick(@Param("uid") String uid,@Param("num") Integer num);

    /**
     * 设为封面
     * @param fileUid
     * @param uid
     */
    @Select("update t_picture_sort set parent_uid=#{uid} where file_uid=#{fileUid}")
    void setCover(@Param("fileUid") String fileUid,@Param("uid") String uid);
}
